package com.honey.compilation.sql.ddl;

import com.honey.compilation.sql.SqlKeyWord;
import com.honey.compilation.sql.ValueElement;
import com.honey.core.builder.CharacterBuilder;
import com.honey.core.builder.CharacterBuilderFactory;
import com.honey.core.compiler.CompilationException;
import com.honey.core.exception.UncheckedException;
import com.honey.core.utils.StringUtility;

/**
 * 修改表命令: ALERT Database ,非SQL 92 定义
 * @author Administrator
 */
@Deprecated
public class AlterDatabase extends Alter{
	
	/** 数据库 */
	public ValueElement databaseName ;
	
	/** 附加字符串 */
	public ValueElement append;
	
	/**
	 * 构造函数
	 * @param databaseName 
	 * @param append 
	 */
	public AlterDatabase(String databaseName,String append){
		if(StringUtility.stringHasValue(databaseName)){
			this.databaseName = new ValueElement( databaseName );
		}else{
			throw new UncheckedException("没有传入数据库名称");
		}
		this.append =new ValueElement( append ); 
	}

	/*
	 * (non-Javadoc)
	 * @see com.honey.core.dom.sql.ddl.Alter#compiledContent(int)
	 */
	@Override
	public CharacterBuilder compiledContent(int indentLevel ) throws CompilationException {
		CharacterBuilder answer = CharacterBuilderFactory.createC16StringBuilder() ;
		if( append != null || StringUtility.stringHasValue(append.getValue()) ){
			answer.append( super.compiledContent(indentLevel) ) 
			.append( SqlKeyWord.DATABASE )
			.append( databaseName )
			.append( append)
			.append(SqlKeyWord.OPERATION_SEMICOLON);
		}
		return answer;
	}
}
